<?php

namespace common\models\inventory;

use Yii;

/**
 * This is the model class for table "{{%inventory_log}}".
 *
 * @property int $id
 * @property int $batch_id
 * @property int $bill_id 票据ID
 * @property int $rf_id 电子标签ID
 * @property string $sn
 * @property string $data
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property int $deleted_at 删除时间
 */
class InventoryLog extends \common\db\ActiveRecord {

    const STATUS_DEFAULT = 0;
    const STATUS_COMPLETED = 1;
    const STATUS_UNDEFIND = -1;
    const STATUS_ACTIVE = 10;

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%inventory_log}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['batch_id', 'bill_id', 'rf_id', 'status', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
            [['sn', 'data'], 'string', 'max' => 32],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'batch_id' => 'Batch ID',
            'bill_id' => '票据ID',
            'rf_id' => '电子标签ID',
            'sn' => 'Sn',
            'data' => 'Data',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'deleted_at' => '删除时间',
        ];
    }

    public function getBill() {
        return $this->hasOne(InventoryBill::className(), ['id' => 'bill_id']);
    }

    public function fields() {
        return [
            'id',
            'batch_id',
            'bill_id',
            'rf_id',
            'sn',
            'data',
            'status',
            'bill'
        ];
    }

}
